//
//  RNOLDismissAnimationTransition.m
//  RongNiuOnline
//
//  Created by apple on 2018/5/21.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLDismissAnimationTransition.h"

@implementation RNOLDismissAnimationTransition
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
    return 0.6;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    //当前的frame
    CGRect targetFrame = [transitionContext initialFrameForViewController:fromVC];
    //dismiss后的frame
    targetFrame = CGRectOffset(targetFrame, 0,  CGRectGetHeight(targetFrame));
    
    [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
        fromVC.view.frame = targetFrame;
    } completion:^(BOOL finished) {
        [transitionContext completeTransition:YES];
    }];
}

@end
